﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using Lottery.Control;

namespace Lottery.MediaData.UI.Control {
    public partial class DataLimitInput : UserControl {
        private List<DataLimit> allDataLimits = new List<DataLimit>();

        public DataLimitInput() {
            InitializeComponent();

            for (int i = 0; i < 42; i++) {
                DataLimit dl = new DataLimit();
                flowLayoutPanel.Controls.Add(dl);
                allDataLimits.Add(dl);
            }

            for (int i = 0; i < allDataLimits.Count - 1; i++) {
                allDataLimits[i].JumpToNext = allDataLimits[i + 1];
            }

            HideAll();
        }

        public DataLimit this[int index] { get { return allDataLimits[index]; } }

        public void HideAll() {
            this.Visible = false;
            for (int i = 0; i < allDataLimits.Count; i++) {
                allDataLimits[i].Visible = false;
            }
            this.Visible = true;
        }

        /// <summary>
        /// 控件的个数
        /// </summary>
        public int Count { get { return allDataLimits.Count; } }

        /// <summary>
        /// 可见的控件个数
        /// </summary>
        public int VisibleCount {
            get {
                var result = 0;
                for (int i = 0; i < this.Count; i++) {
                    var item = allDataLimits[i];
                    if (item.Visible) result++;
                }
                return result;
            }
        }
    }
}
